<?php $this->pageTitle = 'Обсуждения'; ?>
<div class="cat_head_members">
	<div class="cat_head_strip"></div>
	<?php // кнопка "Новая тема"
		echo CHtml::link( 
			'<i>+</i>Новая тема',
			$this->createUrl('groupsDiscussion/create',array('group'=>$_GET['group'])),
			array(
				'class'=>'green_btn r_m'
			)
		);
	?>
	<div class="cat_head_h t">
		<p class="cat_head_h_txt">
			В сообществе <span><?php echo CHtml::encode(count( $model )); ?></span> обсуждений
		</p>
		<a class="cat_head_h_edit" href="<?php echo Yii::app()->createUrl('groups/view',array('group'=>$_GET['group']));?>">назад</a>
	</div>
</div>
<div class="clear"></div>

<?php foreach ($model as $key => $discussion) : ?>
<div class="f_dialog_item">
	<div class="f_dialog_item_l">
		<div class="u_buzz_item_l">
			<?php 
				echo CHtml::link( 
					CHtml::image( $discussion->lastUser->avatar_info!=NULL ? '/upload/photos/'. $discussion->lastUser->id . '/0/' . $discussion->lastUser->avatar_info->name : '/upload/noimage.gif', 
						CHtml::encode($discussion->lastUser->full_name), 
						array(
							'width'		=>	'50px',
							'height'	=>	'50px',
							'border'	=>	'0',
						)), 
					$this->createUrl('profile/index',array('id' => $discussion->lastUser->id)),
					array('class'=>'u_friend_pic')
				);
			?>
		</div>
		<div class="u_buzz_item_r">
			<div class="u_buzz_name_members">
				<?php 
					echo CHtml::link( 
						CHtml::encode($discussion->lastUser->full_name),
						$this->createUrl('profile/index',array('id' => $discussion->lastUser->id))
					);
				?>
				<p class="u_buzz_date">
					<?php echo ($discussion->countComments == 0) ?  'написал' :  'ответил'; ?></p>
				<p class="u_buzz_date">
					<?php echo Yii::app()->dateFormatter->formatDateTime($discussion->update, 'long','short'); ?></p>
			</div>
		</div>
	</div>
	<div class="f_dialog_item_r">
		<table class="f_dialog_item_text">
			<tr>
				<td>
					<?php 
						echo CHtml::link(CHtml::encode($discussion->name),
							$this->createUrl('groupsDiscussion/view', array('discussion'=>$discussion->id, 'group'=>$_GET['group']))
						);
					?>
					<p><?php echo CHtml::encode($discussion->countComments + 1); ?> сообщения</p>
				</td>
			</tr>
		</table>
		<div class="u_buzz_link_block hidden">
			<?php 
			if($discussion->group->checkAdmin || $discussion->user_id == Yii::app()->user->id) {
				echo CHtml::link('',
					$this->createUrl('groupsDiscussion/deleteDiscussion', array('discussion'=>$discussion->id, 'group'=>$_GET['group'])),
					array(
						'class'=>'u_buzz_link l2 removeLink',
					)
				);
			}
			?>
		</div>
	</div>
</div>
<?php endforeach; ?>